package com.fh.controller.system.log;

import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
 * 记录日志
 * 
 * @author dell、
 *
 */
import org.springframework.web.servlet.ModelAndView;

import com.fh.controller.base.BaseController;
import com.fh.model.Page;
import com.fh.service.system.log.IOperatorLogService;
import com.fh.util.PageData;
@Controller
@RequestMapping("system")
public class OperatorLogController extends BaseController{
	
	@Autowired
	private IOperatorLogService service;
	/**
	 * 查看日志
	 * 
	 * @param page
	 * @return
	 */
	@RequestMapping("log")
	public ModelAndView index(Page page){
		ModelAndView mv = this.getModelAndView();
		PageData pd = new PageData();
		pd = this.getPageData();
		//获取页面参数去空并射入page里面
        PageData pageData = this.setPdWithTrim(this.getPageData());
        page.setPd(pageData);
		List<PageData> pageList = service.querylistPage(page);
		mv.setViewName("system/log/list");
		mv.addObject("pageList", pageList);
		mv.addObject("pd", pd);
		return mv;
	}
	
	 /**
     * map 循环去空
     * @param pd 传入参数Map
     */
    public PageData setPdWithTrim(PageData pd){
        //循环去空
        Iterator it = pd.entrySet().iterator();
        Map.Entry entry;
        while (it.hasNext()) {
            entry = (Map.Entry) it.next();
            Object valueObj = entry.getValue();
            pd.put((String) entry.getKey(), null == valueObj ? "" : valueObj.toString().trim());
        }
        return pd;
    }
	
}
